/** @file bt_dev.h
  *
  * @brief This file contains definitions for driver context structure
  * of Bluetooth driver.
  * 
  * (c) Copyright 2003-2007, Marvell International Ltd.
  * All Rights Reserved
  */

#ifndef _BT_DEV_H_
#define _BT_DEV_H_

#include <SDCardDDK.h>
#include "bt_def.h"

#ifdef __cplusplus
extern "C" {
#endif //__cplusplus

#pragma pack(4)

typedef struct _MRVDRV_ADAPTER
{
    SD_DEVICE_HANDLE        hDevice;        // SD device handle
    ULONG                   SetSD4BIT;
    ULONG                   FunctionNumber;
    ULONG                   SdioFastPath;   // 0: disable, 1: enable.
    UCHAR                   gHostIntStatus;
    ULONG                   SdioIstThreadPriority;
    BOOL                    CardRemoved;
    BOOL                    bIsOpenConnection;

    // Device Power State
    UCHAR                   psmode;
    UCHAR                   ps_state;
    UCHAR                   hs_state;

    // Handle for Thread
    HANDLE                  hControllerInterruptThread;
#ifdef INIT_THREAD
    HANDLE                  hInitialThread;
#endif

    // Handle for Event
    HANDLE                  hControllerInterruptEvent;
    HANDLE                  hThreadReadyEvent;
    HANDLE                  hReadPacketEvent;
    HANDLE                  hPSAwakeEvent;
    HANDLE                  hCmdRespEvent;
#ifdef INIT_THREAD
    HANDLE                  hDelayTimerEvent;
#endif

    // Synchronization Object
    CRITICAL_SECTION        IntCriticalSection;     

    // Rx-related variables 
    Q_KEEPER                RxPacketFreeQueue;
    Q_KEEPER                RxPacketPendQueue;
    CRITICAL_SECTION        RxPacketFreeQLock;
    CRITICAL_SECTION        RxPacketPendQLock;
    PACKET_QUEUE_NODE       *RxPacketQueueNode;
    ULONG                   RxHCIScoDataCnt;
    ULONG                   RxHCIAclDataCnt;
    ULONG                   RxHCIEventPktCnt;
    ULONG                   RxVendorPktCnt;
    ULONG                   RxUnknownPktCnt;
    ULONG                   RxPacketDropCnt;

    // Tx-related variables
    CRITICAL_SECTION        TxCriticalSection;
    UCHAR                   TmpTxBuf[BT_UPLD_SIZE];

    // Command-related variables
    UCHAR                   CurrentCmd;
    BOOL                    bWaitForCmd;

} MRVDRV_ADAPTER, *PMRVDRV_ADAPTER;

extern PMRVDRV_ADAPTER Adapter;

#pragma pack()

#ifdef __cplusplus
}
#endif //__cplusplus

#endif  /* #ifndef _BT_DEV_H_ */
